﻿using System;
using System.ComponentModel;
using System.Reflection;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdDbLayoutPaperPE : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbLayoutPaperPE(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdDbLayoutPaperPE_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbLayoutPaperPE obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbLayoutPaperPE()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbLayoutPaperPE(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public OdDbLayoutPaperPE() : this(TD_DbPINVOKE.new_OdDbLayoutPaperPE(), MemoryManager.GetMemoryManager().GetCurrentTransaction() == null)
		{
			MemoryTransaction currentTransaction = MemoryManager.GetMemoryManager().GetCurrentTransaction();
			if (currentTransaction != null)
			{
				currentTransaction.AddObject(new OdDbLayoutPaperPE(this.swigCPtr.Handle, true));
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			this.SwigDirectorConnect();
		}

		public new static OdDbLayoutPaperPE cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbLayoutPaperPE_cast(OdRxObject.getCPtr(pObj));
			OdDbLayoutPaperPE result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbLayoutPaperPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbLayoutPaperPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbLayoutPaperPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbLayoutPaperPE_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(this.SwigDerivedClassHasMethod("isA", OdDbLayoutPaperPE.swigMethodTypes1) ? TD_DbPINVOKE.OdDbLayoutPaperPE_isASwigExplicitOdDbLayoutPaperPE(this.swigCPtr) : TD_DbPINVOKE.OdDbLayoutPaperPE_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(this.SwigDerivedClassHasMethod("queryX", OdDbLayoutPaperPE.swigMethodTypes0) ? TD_DbPINVOKE.OdDbLayoutPaperPE_queryXSwigExplicitOdDbLayoutPaperPE(this.swigCPtr, OdRxClass.getCPtr(protocolClass)) : TD_DbPINVOKE.OdDbLayoutPaperPE_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdDbLayoutPaperPE createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbLayoutPaperPE_createObject();
			OdDbLayoutPaperPE result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbLayoutPaperPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbLayoutPaperPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbLayoutPaperPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool drawPaper(OdDbLayout pThis, OdGiWorldDraw pWd, OdGePoint3d points)
		{
			bool result = TD_DbPINVOKE.OdDbLayoutPaperPE_drawPaper(this.swigCPtr, OdDbLayout.getCPtr(pThis), OdGiWorldDraw.getCPtr(pWd), OdGePoint3d.getCPtr(points));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool drawBorder(OdDbLayout pThis, OdGiWorldDraw pWd, OdGePoint3d points)
		{
			bool result = TD_DbPINVOKE.OdDbLayoutPaperPE_drawBorder(this.swigCPtr, OdDbLayout.getCPtr(pThis), OdGiWorldDraw.getCPtr(pWd), OdGePoint3d.getCPtr(points));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool drawMargins(OdDbLayout pThis, OdGiWorldDraw pWd, OdGePoint3d points)
		{
			bool result = TD_DbPINVOKE.OdDbLayoutPaperPE_drawMargins(this.swigCPtr, OdDbLayout.getCPtr(pThis), OdGiWorldDraw.getCPtr(pWd), OdGePoint3d.getCPtr(points));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private void SwigDirectorConnect()
		{
			if (this.SwigDerivedClassHasMethod("queryX", OdDbLayoutPaperPE.swigMethodTypes0))
			{
				this.swigDelegate0 = new OdDbLayoutPaperPE.SwigDelegateOdDbLayoutPaperPE_0(this.SwigDirectorqueryX);
			}
			if (this.SwigDerivedClassHasMethod("isA", OdDbLayoutPaperPE.swigMethodTypes1))
			{
				this.swigDelegate1 = new OdDbLayoutPaperPE.SwigDelegateOdDbLayoutPaperPE_1(this.SwigDirectorisA);
			}
			if (this.SwigDerivedClassHasMethod("drawPaper", OdDbLayoutPaperPE.swigMethodTypes2))
			{
				this.swigDelegate2 = new OdDbLayoutPaperPE.SwigDelegateOdDbLayoutPaperPE_2(this.SwigDirectordrawPaper);
			}
			if (this.SwigDerivedClassHasMethod("drawBorder", OdDbLayoutPaperPE.swigMethodTypes3))
			{
				this.swigDelegate3 = new OdDbLayoutPaperPE.SwigDelegateOdDbLayoutPaperPE_3(this.SwigDirectordrawBorder);
			}
			if (this.SwigDerivedClassHasMethod("drawMargins", OdDbLayoutPaperPE.swigMethodTypes4))
			{
				this.swigDelegate4 = new OdDbLayoutPaperPE.SwigDelegateOdDbLayoutPaperPE_4(this.SwigDirectordrawMargins);
			}
			TD_DbPINVOKE.OdDbLayoutPaperPE_director_connect(this.swigCPtr, this.swigDelegate0, this.swigDelegate1, this.swigDelegate2, this.swigDelegate3, this.swigDelegate4);
		}

		private bool SwigDerivedClassHasMethod(string methodName, Type[] methodTypes)
		{
			MethodInfo method = base.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, methodTypes, null);
			return method.DeclaringType.IsSubclassOf(typeof(OdDbLayoutPaperPE));
		}

		private IntPtr SwigDirectorqueryX(IntPtr protocolClass)
		{
			return OdRxObject.getCPtr(this.queryX((OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(protocolClass, false))).Handle;
		}

		private IntPtr SwigDirectorisA()
		{
			return OdRxClass.getCPtr(this.isA()).Handle;
		}

		private bool SwigDirectordrawPaper(IntPtr pThis, IntPtr pWd, IntPtr points)
		{
			return this.drawPaper((OdDbLayout)Teigha.Core.Helpers.odrxCreateObjectInternal(pThis, false), new OdGiWorldDraw_Internal(pWd, false), (points == IntPtr.Zero) ? null : new OdGePoint3d(points, false));
		}

		private bool SwigDirectordrawBorder(IntPtr pThis, IntPtr pWd, IntPtr points)
		{
			return this.drawBorder((OdDbLayout)Teigha.Core.Helpers.odrxCreateObjectInternal(pThis, false), new OdGiWorldDraw_Internal(pWd, false), (points == IntPtr.Zero) ? null : new OdGePoint3d(points, false));
		}

		private bool SwigDirectordrawMargins(IntPtr pThis, IntPtr pWd, IntPtr points)
		{
			return this.drawMargins((OdDbLayout)Teigha.Core.Helpers.odrxCreateObjectInternal(pThis, false), new OdGiWorldDraw_Internal(pWd, false), (points == IntPtr.Zero) ? null : new OdGePoint3d(points, false));
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		private OdDbLayoutPaperPE.SwigDelegateOdDbLayoutPaperPE_0 swigDelegate0;

		private OdDbLayoutPaperPE.SwigDelegateOdDbLayoutPaperPE_1 swigDelegate1;

		private OdDbLayoutPaperPE.SwigDelegateOdDbLayoutPaperPE_2 swigDelegate2;

		private OdDbLayoutPaperPE.SwigDelegateOdDbLayoutPaperPE_3 swigDelegate3;

		private OdDbLayoutPaperPE.SwigDelegateOdDbLayoutPaperPE_4 swigDelegate4;

		private static Type[] swigMethodTypes0 = new Type[]
		{
			typeof(OdRxClass)
		};

		private static Type[] swigMethodTypes1 = new Type[0];

		private static Type[] swigMethodTypes2 = new Type[]
		{
			typeof(OdDbLayout),
			typeof(OdGiWorldDraw),
			typeof(OdGePoint3d)
		};

		private static Type[] swigMethodTypes3 = new Type[]
		{
			typeof(OdDbLayout),
			typeof(OdGiWorldDraw),
			typeof(OdGePoint3d)
		};

		private static Type[] swigMethodTypes4 = new Type[]
		{
			typeof(OdDbLayout),
			typeof(OdGiWorldDraw),
			typeof(OdGePoint3d)
		};

		public delegate IntPtr SwigDelegateOdDbLayoutPaperPE_0(IntPtr protocolClass);

		public delegate IntPtr SwigDelegateOdDbLayoutPaperPE_1();

		public delegate bool SwigDelegateOdDbLayoutPaperPE_2(IntPtr pThis, IntPtr pWd, IntPtr points);

		public delegate bool SwigDelegateOdDbLayoutPaperPE_3(IntPtr pThis, IntPtr pWd, IntPtr points);

		public delegate bool SwigDelegateOdDbLayoutPaperPE_4(IntPtr pThis, IntPtr pWd, IntPtr points);
	}
}
